Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved pre-processing step to Core ML class #25

Merged
merged 1 commit into from
Mar 30, 2021

Conversation

ellbosch
Copy link
Contributor

This PR offloads image preprocessing to the Vision class in Core ML. This should make us better prepared for possible changes to expected image input size in the future.

Because:

  • The Vision class automatically adjusts preprocessing based on the expected image size from the loaded Core ML model. Our prior implementation was naive about the expected format.

This commit:

  • Assigns .centerCrop to the VNCoreMLRequest object.
  • Removes now unused code for squaring the image.
  • Re-orders the LobeML file in the project menu, for kicks.

Tagging #22 because there's a chance that bug gets fixed with this change.

@ellbosch ellbosch requested a review from mbeissinger March 25, 2021 02:47
@@ -72,6 +72,11 @@ class PredictionLayer: NSObject {
}
onComplete(request)
})

/// Set center cropping for the expected image size.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mbeissinger comment code here for your review.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep looks good

@@ -37,11 +37,7 @@ class PlayViewModel: ObservableObject {
.compactMap { $0 } // remove non-nill values
.receive(on: DispatchQueue.global(qos: .userInitiated))
.sink(receiveValue: { [weak self] image in
guard let squaredImage = image.squared() else {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That little bugger 😛

@@ -72,6 +72,11 @@ class PredictionLayer: NSObject {
}
onComplete(request)
})

/// Set center cropping for the expected image size.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep looks good

@ellbosch ellbosch merged commit 807f4fa into master Mar 30, 2021
@ellbosch ellbosch deleted the u/elbosc/63/model-preprocessing branch March 30, 2021 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants